/**
 * Copyright(c) kyle.
 */
package org.example.jvm;

import java.lang.reflect.Field;

/**
 * 字段没有多态性
 *
 * @author kyle
 * @version 1.00.00
 * @since [2020-12-03 12:35]
 * @updateUser [Kyle]
 * @updateRemark [说明本次修改内容]
 * @date [2020-12-03 12:35]
 */
public class FieldHasNoPolymorphic {
    private static class Father{
        public int money=1;
        public Father(){
            money=2;
            showMeTheMoney();
        }

        public void showMeTheMoney() {
            System.out.println("I am Father,i hava $"+money);
        }
    }
    private static class Son extends Father{
        public int money=3;
        public Son(){
            money=4;
            showMeTheMoney();
        }
        @Override
        public void showMeTheMoney() {
            System.out.println("I am Son,i hava $"+money);
        }
    }

    public static void main(String[] args) {
        Father gay=new Son();
        System.out.println("This gay has $"+gay.money);
        System.out.println("This gay has $"+((Son)gay).money);
    }
}
